SETLOCAL
@echo off
REM This requires clang to be installed and in %PATH%
REM http://llvm.org/releases/download.html
REM set PATH=%~dp0;%~dp0bin;%PATH%
REM echo %PATH%

@if /i %1 == R goto fmt_recurse_subdir
@if /i %1 == C goto fmt_current_dir

:fmt_recurse_subdir
@echo formart all files recurse sub directory.
@for /F "usebackq delims==" %%i in (`dir *.cpp *.c *.hpp *.h /s /b`) do "%~dp0clang_format_allman.cmd" "%%i"
@goto :endof

:fmt_current_dir
@echo formart all files in current directory.
@for /F %%i in ('dir /b *.cpp *.c *.hpp *.h') do "%~dp0clang_format_allman.cmd" "%%i"
@goto :endof

:endof
ENDLOCAL

if %ERRORLEVEL% NEQ 0  (
    color cf
    echo clang-format failed, error: %ERRORLEVEL%.
    pause
 ) else (
    color
    echo clang-format success.
 )
